package adapter;

import android.graphics.Color;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.widget.TextView;
import bean.ReceiptsDetailsBean;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.dispatchapp.andlei.R;
import ui.activity.mine.MyWalletActivity;

import java.util.List;

/**
 * @author Andlei
 * @DATE 2019/1/24
 */
public class ReceiptsDetailsAdapter extends BaseQuickAdapter<ReceiptsDetailsBean,BaseViewHolder> {
    public ReceiptsDetailsAdapter(int layoutResId, @Nullable List<ReceiptsDetailsBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ReceiptsDetailsBean item) {
        helper.setText(R.id.tv_remark,item.getRemarks());
        helper.setText(R.id.tv_time,item.getAdd_time());
        TextView textView =  helper.getView(R.id.tv_money);
        if(!TextUtils.isEmpty(item.getMoney())){
            if(Double.parseDouble(item.getMoney())>0){
                textView.setTextColor(Color.parseColor("#181830"));
            }else {
                textView.setTextColor(Color.parseColor("#FF4F54"));
            }

        }
        try {
            textView.setText(MyWalletActivity.changeF2Y(item.getMoney()));
        } catch (Exception e) {
            e.printStackTrace();
            textView.setText("金额格式错误");
        }
    }
}
